from pymatgen import Element
from pymatgen.io.vaspio import Poscar, Potcar, Oszicar
from pymatgen.symmetry.finder import SymmetryFinder
#from pymatgen.io.vaspio_set import VaspInputSet
#import os, tempfile, shutil
from vasp import Vesta

# Try to generate the Ni cell (or NiAl3).
# What happens when reading a file with Va, or "Va,C,N" - python automatic generics, use this

#def vesta_view_structure(structure):
#    poscar = Poscar(structure)
#    poscar.write_file('/tmp/POSCAR')
#    os.system('~/VESTA-x86_64/VESTA /tmp/POSCAR')

poscar = Poscar.from_file("/home/mbjba/shang/str83/POSCAR")
#poscar = Poscar.from_file("/home/mbjba/runphon/POSCAR")
struct = poscar.struct

#fitfc(struct, 7)

#SymmetryFinder(struct).get_spacegroup_number()
#start_vesta(struct)

#poscar2 = Poscar(struct)
#poscar2.write_file('/tmp/POSCAR')
#struct.sites[0].specie = Element('H')
#Vesta(struct).show()
#print(2)

oszicar = Oszicar('/home/mbjba/runphon/OSZICAR')
print('{0:.2f} {1}'.format(1, oszicar.final_energy))

for v in [0.97, 0.98, 0.99, 1, 1.01, 1.02, 1.03, 1.04]:
    oszicar = Oszicar('/home/mbjba/runphon/vol_{0:.2f}/OSZICAR'.format(v))
    print('{0:.2f} {1}'.format(v, oszicar.final_energy))

print('Done')
